package com.test;

import javax.jms.*;

/**
 * Created by Administrator on 2016/3/14.
 */
public class ConsumerMessageListener implements MessageListener {

    private TopicSubscriber subscriber;

    public ConsumerMessageListener(TopicSubscriber subscriber) throws JMSException {
        this.subscriber = subscriber;
        subscriber.setMessageListener(this);
    }

    public void onMessage(Message message) {
        TextMessage textMessage = (TextMessage) message;
        try {
            System.out.println("subscriber" + subscriber + "：" + textMessage.getText());
        } catch (JMSException e) {
            e.printStackTrace();
        }
    }

}
